<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%--
  Created by IntelliJ IDEA.
  User: David
  Date: 2019/12/22
  Time: 21:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java"  pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title></title>
    <script type="text/javascript" src="js/base-loading.js"></script>
    <link rel="stylesheet" type="text/css" href="jquery/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="jquery/themes/icon.css">
    <script type="text/javascript" src="jquery/jquery-3.5.1.min.js"></script>
    <script type="text/javascript" src="jquery/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="jquery/jquery_add_tab.js"></script>
    <script type="text/javascript" src="jquery/locale/easyui-lang-zh_CN.js"></script>
</head>
<body>

<div id="cc" class="easyui-layout" style="width:100%;height:500px">
    <div data-options="region:'center',title:'导入审核管理'" fit=true style="width: 100%;height: 100%;">
        <table id="dataGrid"></table>
    </div>
</div>
<div id="gridToolbar">
    <a href="javascript:;" onclick="check(2)" class="easyui-linkbutton" data-options="iconCls:'icon-ok',plain:true">审核通过</a>
    <a href="javascript:;" onclick="check(1)" class="easyui-linkbutton" data-options="iconCls:'icon-no',plain:true">审核不通过</a>
</div>


<script type="text/javascript">
    /**
     * 解决丢它老母的IE缓存问题
     */
    jQuery(function($) {
        jQuery.ajaxSetup({
            cache : false
        });
    });
    $(function() {
        //数据表管理 dataGrid
        $('#dataGrid').datagrid({
            columns:[[
                {field:'serialNo',title:'SERIALNO',width:100,hidden:true},
                {field:'tableId',title:'表标识',width:100,hidden:true},
                {field:'tableComment',title:'所属数据表',width:100,align:'center'},
                {field:'createUser',title:'创建用户',width:100,align:'center',formatter: function(value,row,index){
                        if (value == 'null'){
                            return '';
                        }
                        return value;
                    }},
                {field:'makeUser',title:'审核用户',width:100,align:'center',formatter: function(value,row,index){
                        if (value == 'null'){
                            return '';
                        }
                        return value;
                    }},
                {field:'makeStatus',title:'审核状态',width:100,align:'center',formatter: function(value,row,index){
                        if (value == '0'){
                            return '未审核';
                        } else if (value == '1') {
                            return '审核不通过';
                        } else if (value == '2') {
                            return '审核通过';
                        }
                    }},
                {field:'createDate',title:'创建日期',width:100,align:'center'},
                {field:'createTime',title:'创建时间',width:100,align:'center'},
                {field:'makeDate',title:'审核日期',width:100,align:'center',formatter: function(value,row,index){
                        if (value == 'null'){
                            return '';
                        }
                        return value;
                    }},
                {field:'makeTime',title:'审核时间',width:100,align:'center',formatter: function(value,row,index){
                        if (value == 'null'){
                            return '';
                        }
                        return value;
                    }}
            ]],
            fit: true,
            url: '${serverUrl}/checkLog',
            method: "GET",
            toolbar: "#gridToolbar",
            pagination: true,
            singleSelect: true,
            pageNumber: 1,
            pageSize: 10,
            pageList: [10,20,30]
        });
    })

    function check(status) {
        var rows = $("#dataGrid").datagrid('getSelections');
        if (rows.length != 1) {
            $.messager.alert('提示', '请选择一行数据进行操作!', 'info');
            return;
        }
        var row = rows[0];
        if (row.makeStatus == '1' || row.makeStatus == '2') {
            $.messager.alert('提示', '请选择未审核数据进行操作!', 'error');
            return;
        }
        row.makeStatus = status;
        $.messager.progress({text: '审核中请稍等!'});
        $.ajax({
            url: '${serverUrl}/checkLog',
            type: 'PUT',
            dataType: 'JSON',
            contentType: "application/json",
            data: JSON.stringify({
                data: row,
                loginId: 'admin'
            }),
            success: function (res) {
                if (res.code == "000000") {
                    $.messager.alert('提示', "处理成功", "info");
                } else {
                    $.messager.alert('提示', res.msg, "error");
                }
                $("#dataDialog").dialog('close');
                $('#dataGrid').datagrid('reload');
                $.messager.progress('close');
            },
            error: function (error) {
                $.messager.progress('close');
                $.messager.alert('提示', "处理失败", "error");
            }
        })



    }


</script>
</body>
</html>
